function [vol1 vol2] = SplitKidneys(image,planefn)

if nargin < 2
    planefn = [924 11676 3215 4152806];
end

if numel(planefn) ~= 4
    errordlg('SplitKidneys: plane does not have 4 elements (x1*i + x2*j + x3*k = x4).','Split kidney error','modal');
    return;
end

vol1 = zeros(size(image));
vol2 = zeros(size(image));
for i=1:size(image,1) 
    for j=1:size(image,2) 
        for k=1:size(image,3)
            %if ((-24*i+3264*j+936*k)>1083938)
             if ((planefn(1)*i + planefn(2)*j + planefn(3)*k) > planefn(4))
                vol1(i,j,k)=image(i,j,k);
            else
                vol2(i,j,k)=image(i,j,k);
            end
        end
    end
end


%
%
%
%
% P1 = [305,266,238];
% P2 = [166,277,238];
% P3 = [316,242,322];
% normal = cross(P1-P2, P1-P3)
% syms x y z
% P = [x,y,z]
% planefunction = dot(normal, P-P1)
% 
% planefunction =
%  
% 924*x + 11676*y + 3215*z - 4152806